package com.hairline.controller;

import com.hairline.bean.vo.BaseRespVo;
import com.hairline.bean.vo.StatGoods;
import com.hairline.bean.vo.StateOrder;
import com.hairline.bean.vo.StateUser;
import com.hairline.service.ServiceStat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@RestController
public class StatController {
    @Autowired
    ServiceStat serviceStat;

    @RequestMapping("admin/stat/user")
    public BaseRespVo user(){
        List<StateUser> stateUsers = serviceStat.getStateUser();
        List<String> coulums = new ArrayList<>();
        coulums.add("day");
        coulums.add("users");

        HashMap<String, Object> map = new HashMap<>();
        map.put("columns",coulums);
        map.put("rows",stateUsers);
        return BaseRespVo.ok(map);
    }

    @RequestMapping("admin/stat/order")
    public BaseRespVo order(){
        StateOrder stateOrder = serviceStat.getStatOrder();
        HashMap<String, Object> map = new HashMap<>();
        map.put("columns",stateOrder.getColumns());
        map.put("rows",stateOrder.getRows());
        return BaseRespVo.ok(map);
    }

    @RequestMapping("admin/stat/goods")
    public BaseRespVo goods(){
        List<String> coulums = new ArrayList<>();
        coulums.add("day");
        coulums.add("orders");
        coulums.add("products");
        coulums.add("amount");
        HashMap<String, Object> map = new HashMap<>();
        map.put("columns",coulums);
        List<StatGoods> statGoodsList = serviceStat.getStatGoods();
        map.put("rows",statGoodsList);
        return BaseRespVo.ok(map);
    }
}
